import { defineStore } from 'pinia'
import piniaPersistConfig from '../../piniaPersist'

export const useCalendarStore = defineStore('calendar-store', {
    state: (): Calendar.Setting => ({
        trainInfoList: [],
    }),
    actions: {
        /** 批量导入日程信息 */
        importTrainInfo(newTrainInfoList: Calendar.TrainInfo[]) {
            this.trainInfoList = this.trainInfoList.concat(newTrainInfoList)
        },
        /** 添加单条日程信息 */
        addTrainInfo(newTrainInfo: Calendar.TrainInfo) {
            this.trainInfoList.push(newTrainInfo)
        },
    },
    persist: piniaPersistConfig('calendar')
})
